import json

def load_json(json_str,id,thresh):
    data = []
    with open(json_str) as f:
        new_dict = json.load(f)
        for image_info in new_dict:
            if image_info["category_id"]==id and image_info["score"] <thresh:
                continue
            data.append(image_info)
    return data
def write_json(json_str,data):
    with open(json_str,"w") as f:
        json.dump(data,f)
        print("加载入文件完成...")   

if __name__=='__main__':
    json_str = './bbox.json'
    write_dir = "./filter_bbox.json"
    data = load_json(json_str,1,0.5)
    write_json(write_dir,data)